1. Field of the Invention
Methods and apparatuses consistent with the present invention relate to encoding and decoding an image, and more particularly, to encoding an image by determining whether prediction modes of neighboring blocks of a current block that is predicted with a skip mode are skip modes and assigning more bits to a current block with a high probability of acting as a reference block for other subsequent blocks, and to decoding the encoded image.
2. Description of the Related Art
Image compression standards, such as moving picture experts group (MPEG)-1, MPEG-2, MPEG-4, and H.264/MPEG-4 advanced video coding (AVC), divide one picture into macroblocks in order to encode an image. After each of the macroblocks is encoded in all inter-prediction and intra-prediction modes, one of the prediction modes is selected according to a bit rate required to encode each macroblock and a distortion level between each original macroblock and decoded macroblock.
H.264/MPEG-4 AVC roughly divides one picture into one of I, B, and P slices, and divides the slice into a plurality of macroblocks. The macroblocks are encoded in two prediction modes, that is, an inter mode and an intra mode.
An inter mode is a mode used in inter-prediction that encodes macroblocks of a current picture by encoding a difference between a pixel value and information on a motion vector indicating the position of at least one block selected from a reference picture. Since H.264/MPEG-4 AVC has no more than 5 reference pictures, a reference block to which a current macroblock refers is searched for in a frame memory storing reference pictures. The reference pictures stored in the frame memory may precede or follow the current picture.
An intra mode is a mode used in intra-prediction that encodes macroblocks of a current picture by calculating a prediction value of a macroblock to be encoded by using a pixel value of a pixel spatially close to the macroblock to be encoded and encoding a difference between the prediction value and the pixel value.
FIG. 1 illustrates conventional inter-prediction modes for motion estimation and compensation in H.264/MPEG-4 AVC. One 16×16 macroblock may be divided into two 16×8 blocks, two 8×16 blocks, or four 8×8 blocks, and each of the 8×8 blocks may be further divided into two 8×4 blocks, two 4×8 blocks, or four 4×4 blocks. Each of the macroblocks is encoded in the inter-prediction modes, and then a prediction mode incurring the least cost is determined according to a bit rate required to encode each macroblock and a distortion level between each original macroblock and decoded macroblock.
Also, in H.264/MPEG-4 AVC, in addition to the prediction modes shown in FIG. 1, there is a skip mode in which each of a plurality of macroblocks is encoded by using only a 1-bit flag when motion vectors of macroblocks included in a P slice are the same as predictive motion vectors or motion vectors of macroblocks included in a B slice are the same as direct motion vectors. In the skip mode, only the 1-bit flag is included in a bitstream as encoding information of the macroblock, and a residual of the macroblock is not encoded. When the macroblock encoded with the skip mode is decoded, a predictive motion vector is generated from motion vectors of neighboring blocks that have already been encoded, and motion compensation is performed by using the predictive motion vector to reconstruct the macroblock.
In general, a macroblock determined to have a skip mode is often present in a background where less motion occurs. In particular, when there is no scene change and a background is fixed, a probability that areas of subsequent frames corresponding to a background area encoded with a skip mode are encoded with skip modes is high. As such, when a block encoded with a skip mode is used as reference data for other blocks, the quality of the other blocks referring to the block encoded with the skip mode may be reduced as the quality of the block encoded with the skip mode is reduced.